package com.hee.erp.modules.entity;

import com.baomidou.mybatisplus.annotation.FieldFill;
import com.baomidou.mybatisplus.annotation.TableField;
import com.baomidou.mybatisplus.annotation.TableId;
import com.baomidou.mybatisplus.annotation.TableName;
import java.io.Serializable;
import java.time.LocalDateTime;
import java.util.List;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;

/**
 * <p>
 * 
 * </p>
 *
 * @author weizehong
 * @since 2022-04-16
 */
@Getter
@Setter
@TableName("t_bus_customer")
@ApiModel(value = "BusCustomer对象", description = "")
public class BusCustomer implements Serializable {

    private static final long serialVersionUID = 1L;

    @TableId("id")
    private String id;

    @ApiModelProperty("客户编号")
    @TableField("customer_no")
    private String customerNo;

    @ApiModelProperty("客户来源")
    @TableField("customer_source")
    private String customerSource;

    @ApiModelProperty("客户名称")
    @TableField("customer_name")
    private String customerName;

    @ApiModelProperty("客户简称")
    @TableField("short_name")
    private String shortName;

    @ApiModelProperty("地址")
    @TableField("address")
    private String address;

    @ApiModelProperty("邮编")
    @TableField("post_code")
    private String postCode;

    @ApiModelProperty("客户类型")
    @TableField("customer_type")
    private Integer customerType;

    @TableField(exist = false)
    private String customerTypeName;

    @ApiModelProperty("纳税类型")
    @TableField("pay_tax_type")
    private Integer payTaxType;

    @TableField(exist = false)
    private String payTaxTypeName;

    @ApiModelProperty("所属行业")
    @TableField("trade_type")
    private String tradeType;

    @ApiModelProperty("省编号")
    @TableField("province_id")
    private Integer provinceId;

    @TableField(exist = false)
    private String provinceName;

    @ApiModelProperty("市编号")
    @TableField("city_id")
    private Integer cityId;

    @TableField(exist = false)
    private String cityName;

    public String getRegion(){
        return this.provinceName + this.cityName;
    }

    @ApiModelProperty("营业执照")
    @TableField("business_license")
    private String businessLicense;

    @ApiModelProperty("开户许可证")
    @TableField("account_opening_permit")
    private String accountOpeningPermit;

    @ApiModelProperty("一般纳税人证明")
    @TableField("taxpayer_certificate")
    private String taxpayerCertificate;

    /**
     * 客户联系人
     */
    @TableField(exist = false)
    private List<BusCustomerContact> contactList;
    /**
     * 开票信息
     */
    @TableField(exist = false)
    private BusCustomerBillingInfo billingInfo;

    /**
     * 拜访记录
     */
    @TableField(exist = false)
    private List<BusCustomerVisit> visitList;

    /**
     * 负责人
     */
    @TableField(exist = false)
    private List<BusCustomer2User> customerManagerList;

    public String getCustomerManagerName(){
        StringBuilder sb = new StringBuilder();
        if(this.customerManagerList != null){
            for(BusCustomer2User principal : this.customerManagerList){
                sb.append(principal.getUserName()).append(",");
            }
        }
        return sb.toString();

    }

    @TableField(value = "del_flag",fill = FieldFill.INSERT)
    private Boolean delFlag;

    @TableField(value = "create_user",fill = FieldFill.INSERT)
    private String createUser;

    @TableField(value = "create_time",fill = FieldFill.INSERT)
    private LocalDateTime createTime;

    @TableField(value = "modify_user",fill = FieldFill.INSERT_UPDATE)
    private String modifyUser;

    @TableField(value = "modify_time",fill = FieldFill.INSERT_UPDATE)
    private LocalDateTime modifyTime;

    @TableField(exist = false)
    private String createUserName;

}
